<template>
  <div class="app-container">
    <div class="-box">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label=":用户名" prop="userName">
          <el-input v-model="ruleForm.userName"></el-input>
        </el-form-item>
        <el-form-item label="性别:" prop="sex" placeholder="请选择性别">
          <!--表单选择-->
          <el-radio v-model="ruleForm.sex" label="0">男</el-radio>
          <el-radio v-model="ruleForm.sex" label="1">女</el-radio>
        </el-form-item>
        <el-form-item label="所属部门:" prop="name">
          <el-select v-model="ruleForm.name" placeholder="请选择品种">
            <el-option label="资源管理部" value="ziyuan"></el-option>
            <el-option label="采购部" value="caigou"></el-option>
            <el-option label="信息技术部" value="xinxi"></el-option>
            <el-option label="行政部" value="xingzheng"></el-option>
            <el-option label="运输部" value="yunshu"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="出生日期:" required>
          <el-col :span="11">
            <el-form-item prop="birth">
              <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.birth" style="width: 200px;"><yyyy-MM-dd></yyyy-MM-dd></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
        </el-form-item>
        <el-form-item label="邮箱:" prop="email">
          <el-input v-model="ruleForm.email"></el-input>
        </el-form-item>
        <el-form-item label="电话:" prop="phoneNumber">
          <el-input v-model="ruleForm.phoneNumber"></el-input>
        </el-form-item>
        <el-form-item label="是否禁用:" prop="status">
          <el-input v-model="ruleForm.status"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'add',
    data() {
      return {
        ruleForm: {
          userName: '',
          sex: '',
          name: '',
          birth:'',
          email:'',
          phoneNumber:'',
          status:'',
          ziyuan:'',
          caigou:'',
          xinxi:'',
          xingzheng:'',
          yunshu:'',
        },
        rules: {
          userName: [
            { type: 'date', required: true, message: '请选择名称', trigger: 'change' }
          ],
          sex: [
            { type: 'date', required: true, message: '请选择性别', trigger: 'change' }
          ],
          name: [
            { required: true, message: '请选择品种', trigger: 'change' }
          ],
          birth: [
            { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
          ],
          email: [
            { type: 'date', required: true, message: '请选择名称', trigger: 'change' }
          ],
          phoneNumber: [
            { type: 'date', required: true, message: '请选择名称', trigger: 'change' }
          ],
          status: [
            { type: 'date', required: true, message: '请选择名称', trigger: 'change' }
          ],

        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    },
  }
</script>

<style scoped>

</style>
